var data1 = [{'id':'1','operationtype':'修改类型','operationman':'修改人员','operationdate':'time','modificationcontent':'内容','productname':'text1','email':'text2','cuproductpost':'text3','phone':'text4','mobilephone':'text5','productwechat':'text6','expressaddress':'text7','productbirthday':'text8','productremark':'text9','productman':'text10'}];
var data2 = [{'id':'1','manufacturername':'text1','purchaseorderno':'text2','contracttype':'text3','contractunit':'text4','cdate':'text5','ddate':'text6','placeofdelivery':'text7'},{'id':'2','manufacturername':'text1','purchaseorderno':'text2','contracttype':'text3','contractunit':'text4','cdate':'text5','ddate':'text6','placeofdelivery':'text7'},
    {'id':'3','manufacturername':'text1','purchaseorderno':'text2','contracttype':'text3','contractunit':'text4','cdate':'text5','ddate':'text6','placeofdelivery':'text7'},{'id':'4','manufacturername':'text1','purchaseorderno':'text2','contracttype':'text3','contractunit':'text4','cdate':'text5','ddate':'text6','placeofdelivery':'text7'}];

var layer = layui.layer //弹层
    ,table = layui.table //表格
    ,upload = layui.upload
    ,userphotos="",
    form = layui.form,$ = layui.jquery,id=getQueryVariable("id"),
img_count=0,file_count=0,maincode="",imgs=[],wjs=[];

var tpdata = [{
    "url":"statics/images/layui-logo.jpg",
    "shuom":"说明"
},{
    "url":"statics/images/layui-logo.jpg",
    "shuom":"说明"
},{
    "url":"statics/images/layui-logo.jpg",
    "shuom":"说明"
}];
var fjdata = [{
    "url":"statics/images/layui-logo.jpg",
    "shuom":"说明",
    "name":"文件名"
},{
    "url":"statics/images/layui-logo.jpg",
    "shuom":"说明",
    "name":"文件名"
},{
    "url":"statics/images/layui-logo.jpg",
    "shuom":"说明",
    "name":"文件名"
}];
var cataCodeName=JSON.parse(window.sessionStorage.getItem("cataCodeName"));
var  cataCode=JSON.parse(window.sessionStorage.getItem("cataCode"));
var code=JSON.parse(window.sessionStorage.getItem("code"));
var hs=getdictionary(3,8);//海关
$("input[name='cataCode']").attr("readOnly",true);
$("input[name='cataCode']").val(cataCodeName);
$("input[name='vatRate']").attr("readOnly",true);
$("input[name='taxreRates']").attr("readOnly",true);
$("input[name='importTariff']").attr("readOnly",true);

var hsselect=$("select[name='hgCode']");//客户等级
hsselect.append(getoption(hs));

form.on("select", function(data){
    var hg=data.value;
    for(var i=0;i<hs.length;i++){
        if(hg==hs[i].code){
            $("input[name='vatRate']")[0].value=hs[i].vatRate;
            $("input[name='taxRate']")[0].value=hs[i].taxRate;
            $("input[name='importTariff']")[0].value=hs[i].importTariff;
            break;
        }else{
            $("input[name='vatRate']")[0].value="";
            $("input[name='taxRate']")[0].value="";
            $("input[name='importTariff']")[0].value="";
        }
    }
    form.render();
});
form.render();

//表单初始值，修改时调用
if(id!=""){
    $("input[name='code']").attr("readOnly",true);
    var obj=init(id);//回显
    cataCode=obj.cataCode;
    form.val("editor-form",{
        "code":obj.code,
        "chinaName":obj.chinaName,
        "englishName":obj.englishName,
        "hgCode":obj.hgCode,

        "customerCode":obj.customerCode,
        "gecode":obj.gecode,
        "ge":obj.ge,
        "bzsm":obj.bzsm,
        "cpjz":obj.cpjz,
        "cpmz":obj.cpmz,
        "cataCode":obj.cataCode,
        "remark":obj.remark
    });
    var hg=obj.hgCode;
    for(var i=0;i<hs.length;i++){
        if(hg==hs[i].code){
            $("input[name='vatRate']")[0].value=hs[i].vatRate;
            $("input[name='taxRate']")[0].value=hs[i].taxRate;
            $("input[name='importTariff']")[0].value=hs[i].importTariff;
            break;
        }else{
            $("input[name='vatRate']")[0].value="";
            $("input[name='taxRate']")[0].value="";
            $("input[name='importTariff']")[0].value="";
        }
    }

    tpdata=JSON.parse(obj.img);

    for(var i = 0;i<tpdata.length;i++){
        img_count ++;
        var newImg ='<div class="img_tj">'+
            '<div class="img_wdiv"><img src="'+tpdata[i]+'" id="imgUpload_'+img_count+'"></div>'+
            '<div class="de_div">'+
            /*'<input name="img_instructions'+img_count+'" class="layui-input" placeholder="图片说明" value="'+tpdata[i].shuom+'">'+*/
            '<i class="layui-icon layui-icon-reduce-circle" style="font-size: 30px; color: #000000;line-height: 30px;" id="imgUpload_sc_'+img_count+'"></i>'+
            '</div>'+
            '</div>';
        $('#addimgdiv').append(newImg);
        uploadImgRender("#imgUpload_"+img_count,"#imgUpload_sc_"+img_count);
    }
    fjdata=JSON.parse(obj.wj);
    for(var i = 0;i<fjdata.length;i++){
        file_count ++;
        var filename=fjdata[0].split("filename=")[1];

        var newFile ='<div class="img_tj">'+
            '<div class="file_wdiv"><a id="file_span'+file_count+'" download="'+filename+'" href="'+fjdata[i]+'">'+filename+'</a><a type="button" class="layui-btn" id="fileUpload_'+file_count+'"><i class="layui-icon"></i>上传附件</a></div>'+
            '<div class="de_div">'+
           /* '<input name="file_instructions'+file_count+'" class="layui-input" placeholder="附件说明" value="'+fjdata[i].shuom+'">'+*/
            '<i class="layui-icon layui-icon-reduce-circle" style="font-size: 30px; color: #000000;line-height: 30px;" id="fileUpload_sc_'+file_count+'"></i>'+
            '</div>'+
            '</div>';
        $('#addfilediv').append(newFile);
        uploadFileRender("#fileUpload_"+file_count,"#fileUpload_sc_"+file_count,"#file_span"+file_count);
    }

    form.render();
}
function init(id){
    var obj=[];
    $.ajax({
        type : 'get',
        //  url : 'resource/getTree',
        data:{"id":id},
        url:'productmaininfo/queryById',
        dataType:"json",
        /*
                     contentType: 'application/json',
        */
        async:false,
        success : function (da) {
            if(da.status==200 ){
               obj=da.data;

            }
        },
        error: function(data) {
            // layer.msg("获取失败!");
        }
    });
    return obj;
}
//---产品查询
table.render({
    elem: '#productselect'
    //,data:data2
    ,type:"get"
    ,url:"productfjinfo/selectByPage"
    ,where:{
        "code":code
    }
    ,toolbar: '#producttoolbar'
    ,cols: [[
        {checkbox: true, fixed: true}
        ,{field: 'code', title: '规格编码',event:'specificationcoding', width: 120, sort: true}
        ,{field: 'ge', title: '规格说明', width: 120, sort: true}
        ,{field:'chinaRemark', title:'中文描述', width: 120, sort: true}
        ,{field:'englishRemark', title:'英文描述', width: 120, sort: true}
        ,{field:'bzsm', title:'包装说明', width: 120, sort: true}
        ,{field:'cpjz', title:'产品净重', width: 120, sort: true}
        ,{field:'cpmz', title:'产品毛重', width: 120, sort: true}
        ,{field: 'colour', title: '颜色', width: 120, sort: true}
        ,{field:'dw', title:'单位', width: 120, sort: true}
        ,{field:'cgbz', title:'采购币种', width: 120, sort: true}
        ,{field:'cgcb', title:'采购成本', width: 120, sort: true}
        ,{field:'fob', title:'FOB价', width: 120, sort: true}
        ,{field:'wbzc', title:'外包装长', width: 120, sort: true}
        ,{field:'wbzk', title:'外包装宽', width: 120, sort: true}
        ,{field:'wbzg', title:'外包装高', width: 120, sort: true}
        ,{field:'wbzcc', title:'外包装尺寸', width: 120, sort: true}
        ,{field:'wbzsl', title:'外包装数量', width: 120, sort: true}
        ,{field:'tj', title:'体积', width: 120, sort: true}
        ,{field:'gys', title:'供应商', width: 120, sort: true}
        ,{field:'cshh', title:'厂商货号', width: 120, sort: true}
        ,{field:'hq40zl', title:'40HQ装量', width: 120, sort: true}
        ,{field:'gp20', title:'20GP', width: 120, sort: true}
        ,{field:'gp40', title:'40GP', width: 120, sort: true}
        ,{field:'lclpx', title:'LCL拼箱', width: 120, sort: true}
        ,{fixed: 'right', width:150, align:'center', toolbar: '#productup', title:'操作'}
    ]]
    ,id: 'producttableid'
    ,page: true
    ,height:300
});
//新增、删除
table.on('toolbar(producttable)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    var data = checkStatus.data;
    switch(obj.event){
        case 'new':
            if(id =="" ){
                layer.msg("请先保存产品主信息");
                return false;
            }
            // layer.msg("添加");
            layer.open({
                type: 2,
                area: ['1488px', '800px'],
                content: 'views/jsp/BasicData/tpl/newupproductspecification.jsp'
            });
            break;
        case 'delet':
            var data=checkStatus.data,delList=[];
            data.forEach(function(n,i){
                delList.push(n.id);
            });
            if(delList!=''){
                layer.confirm('确定删除所选项吗？',function (index) {
                    if(delfjinfo(delList)){
                        layer.msg('删除成功');
                        layer.close(index);
                        refrash();
                    }else{
                        layer.msg('删除失败');
                    }

                })
            }else{
                layer.msg('请选择需要删除的行');
            }
            break;
    };
});
//行内修改、删除
table.on('tool(producttable)', function(obj){
    var data = obj.data;
    if(obj.event === 'productup') {
        layer.open({
            type: 2,
            area: ['1488px', '800px'],
            content: 'views/jsp/BasicData/tpl/newupproductspecification.jsp?id='+obj.data.id
        });
        // layer.msg('修改');
    }else if(obj.event === 'productde') {
        layer.confirm('真的删除行么', function (index) {
            var delList=[];
            delList.push(data.id);
            if(delfjinfo(delList)){
                layer.msg('删除成功');
                layer.close(index);
                refrash();
            }else{
                layer.msg('删除失败');
            }
            //obj.del();

        });
    }
   /* else if(obj.event === 'specificationcoding') {
        $("#hidden").show();
        table.render({
            elem: '#productsaselect'
            ,data:data2
            ,toolbar: '#productsatoolbar'
            ,where:{id:obj.data.id} //查询的产品ID，条件
            ,cols: [[
                {checkbox: true, fixed: true}
                ,{field: 'productcode', title: '产品编码', sort: true}
                ,{field: 'specificationcoding', title: '规格编码', sort: true}
                ,{field:'finishedproductratio', title:'成品比例', sort: true}
                ,{field:'accessoriesproportion', title:'配件比例', sort: true}
                ,{field:'chinesename', title:'中文名称', sort: true}
                ,{field:'englishnames', title:'英文名称', sort: true}
                ,{field:'expressaddress', title:'毛重', sort: true}
                ,{field:'netweight', title:'净重', sort: true}
                ,{field:'volume', title:'体积', sort: true}
                ,{fixed: 'right', width:150, align:'center', toolbar: '#productsaup', title:'操作'}
            ]]
            ,id: 'productsatableid'
            ,page: true
            ,height:300
        });

        table.render({
            elem: '#asupplierselect'
            ,data:data2
            ,toolbar: '#asuppliertoolbar'
            ,where:{id:obj.data.id} //查询的产品ID，条件
            ,cols: [[
                {checkbox: true, fixed: true}
                ,{field: 'asupplier', title: '备选供应商', sort: true}
                ,{field: 'manufacturernumber', title: '厂商货号', sort: true}
                ,{field:'purchasingcurrency', title:'采购币种', sort: true}
                ,{field:'procurementcosts', title:'采购成本', sort: true}
                ,{field:'subordinatedirectory', title:'所属目录', sort: true}
                ,{fixed: 'right', width:150, align:'center', toolbar: '#asupplierup', title:'操作'}
            ]]
            ,id: 'asuppliertableid'
            ,page: true
            ,height:300
        });
    }*/
});

table.on('toolbar(productsatable)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    var data = checkStatus.data;
    switch(obj.event){
        case 'new':
            // layer.msg("添加");
            layer.open({
                type: 2,
                area: ['908px', '500px'],
                content: 'views/jsp/BasicData/tpl/newupproductsa.jsp'
            });
            break;
        case 'delet':
            var delid = [];
            for (var i = 0;i<data.length;i++){
                delid.push(data[i].id)
            }
            layer.msg('需要删除的数据ID为：'+ JSON.stringify(delid) + ',执行删除');
            table.reload('productsatableid',{}); //ajax删除成功之后刷新表格
            break;
    };
});
table.on('tool(productsatable)', function(obj){
    var data = obj.data;
    if(obj.event === 'productsaup') {
        layer.open({
            type: 2,
            area: ['908px', '500px'],
            content: 'views/jsp/BasicData/tpl/newupproductsa.jsp?id='+obj.data.id
        });
        // layer.msg('修改');
    }else if(obj.event === 'productsade') {
        layer.confirm('真的删除行么', function (index) {
            obj.del();
            layer.close(index);
        });
    }
});
//新增中的新增产品附件
table.on('toolbar(asuppliertable)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    var data = checkStatus.data;
    switch(obj.event){
        case 'new':
            // layer.msg("添加");
            layer.open({
                type: 2,
                area: ['908px', '380px'],
                content: 'views/jsp/BasicData/tpl/newupasupplier.jsp'
            });
            break;
        case 'delet':
            var delid = [];
            for (var i = 0;i<data.length;i++){
                delid.push(data[i].id)
            }
            layer.msg('需要删除的数据ID为：'+ JSON.stringify(delid) + ',执行删除');
            table.reload('asuppliertableid',{}); //ajax删除成功之后刷新表格
            break;
    };
});
table.on('tool(asuppliertable)', function(obj){
    var data = obj.data;
    if(obj.event === 'asupplierup') {
        layer.open({
            type: 2,
            area: ['908px', '380px'],
            content: 'views/jsp/BasicData/tpl/newupasupplier.jsp?id='+obj.data.id
        });
        // layer.msg('修改');
    }else if(obj.event === 'asupplierde') {
        layer.confirm('真的删除行么', function (index) {
            obj.del();
            layer.close(index);
        });
    }
});
//---日志
table.render({
    elem: '#infoselect'
    ,data:data1
    ,cols: [[
        {field:'operationtype', title:'操作类型', sort: true}
        ,{field:'operationman', title:'操作员名称', sort: true}
        ,{field:'operationdate', title:'更新日期',  sort: true}
        ,{field:'modificationcontent', title:'操作内容', sort: true}
    ]]
    ,id: 'infoselecttableid'
    ,page: true
    ,height:350
});

//监听提交---保存
form.on('submit(form-save)', function(data){
    if(savemain(data.field)){
        layer.msg('保存成功');
    }else{
        layer.msg('保存失败');
    }
   // layer.msg('保存');
    //layui.table.cache[表格ID] 表格数据获取方式
   /* setTimeout(function () {
        //保存成功则刷新提交过来的界面 并关闭此页面
        parent.detab("views/jsp/BasicData/product.jsp");
        parent.intab("views/jsp/BasicData/product.jsp","产品")
        parent.detab("views/jsp/BasicData/tpl/newupproduct.jsp"+(id==''?'':'?id='+id));
    },1000)*/
    return false;
});

//可用于修改动态生成 图片
$("#newimg").on('click',function () {
    img_count ++;
    var newImg ='<div class="img_tj">'+
                    '<div class="img_wdiv"><img src="statics/images/layui-logo.jpg" id="imgUpload_'+img_count+'"></div>'+
                    '<div class="de_div">'+
                        '<input name="img_instructions'+img_count+'" class="layui-input" placeholder="图片说明">'+
                        '<i class="layui-icon layui-icon-reduce-circle" style="font-size: 30px; color: #000000;line-height: 30px;" id="imgUpload_sc_'+img_count+'"></i>'+
                    '</div>'+
                '</div>';
    $('#addimgdiv').append(newImg);
    uploadImgRender("#imgUpload_"+img_count,"#imgUpload_sc_"+img_count);
});

function uploadImgRender(e,uploadimd) {
    var uploadImg = upload.render({
        elem: e
        , url: 'ftp/uploadFile'
        , field: "uploadify"     //添加这个属性与后台名称保存一致
        , accept: 'file' //允许上传的文件类型
        ,data:{"fileType":"productimg"}//头像
        , before: function (obj) {
            //预读本地文件示例，不支持ie8
            obj.preview(function (index, file, result) {
                console.log(uploadImg);
                $(e).attr('src', result); //图片链接（base64）
            });
        }
        , done: function (res) {
            //如果上传失败
            if (res.status !=200) {
                return layer.msg('上传失败');
            }
            //上传成功

               /* var img_sb = img_wdiv.find('.img_sb');
                if(img_sb.length != 0){
                    img_sb.remove();
                }*/

                var ftpPath=res.data[0].ftpPath;
                var fileName=res.data[0].fileName;
                var src=getFtpPath(ftpPath,fileName);
                imgs.push(src);
                return layer.msg('上传成功');


           /* //如果上传失败
            if(res.status !=200){
                return layer.msg('上传失败');
            }else{
                var ftpPath=res.data[0].ftpPath;
                var fileName=res.data[0].fileName;
                var src=getFtpPath(ftpPath,fileName);
                $("#userphotos").attr('src',src);
                $("input[name='logo']")[0].value=src;
            }*/
            //上传成功
        }
        , error: function () {
            //演示失败状态，并实现重传
            var img_wdiv = $(e).parent();
            var img_sb = img_wdiv.find('.img_sb');
            if(img_sb.length == 0){
                img_wdiv.append('<div class="img_sb"><a class="layui-btn layui-btn-xs demo-reload">重试</a></div>');
                img_wdiv.find('.demo-reload').on('click', function () {
                    uploadImg.upload();
                });
            }
        }
    });

    $(uploadimd).on('click',function () {
        $(uploadimd).parent().parent().remove();
    })
}

function uploadImgRender22(e,uploadimd) {
    var uploadImg = upload.render({
        elem: e
        , url: 'https://httpbin.org/post' //改成您自己的上传接口
        , before: function (obj) {
            //预读本地文件示例，不支持ie8
            obj.preview(function (index, file, result) {
                console.log(uploadImg);
                $(e).attr('src', result); //图片链接（base64）
            });
        }
        , done: function (res) {
            //如果上传失败
            if (res.error > 0) {
                return layer.msg('上传失败');
            }
            //上传成功
            if (res.error == 0) {
                var img_sb = img_wdiv.find('.img_sb');
                if(img_sb.length != 0){
                    img_sb.remove();
                }
                return layer.msg('上传成功');
            }
        }
        , error: function () {
            //演示失败状态，并实现重传
            var img_wdiv = $(e).parent();
            var img_sb = img_wdiv.find('.img_sb');
            if(img_sb.length == 0){
                img_wdiv.append('<div class="img_sb"><a class="layui-btn layui-btn-xs demo-reload">重试</a></div>');
                img_wdiv.find('.demo-reload').on('click', function () {
                    uploadImg.upload();
                });
            }
        }
    });

    $(uploadimd).on('click',function () {
        $(uploadimd).parent().parent().remove();
    })
}
//文件
$("#newfile").on('click',function () {
    file_count ++;
    var newFile ='<div class="img_tj">'+
                        '<div class="file_wdiv"><a id="file_span'+file_count+'"></a><a type="button" class="layui-btn" id="fileUpload_'+file_count+'"><i class="layui-icon"></i>上传附件</a></div>'+
                        '<div class="de_div">'+
                            '<input name="file_instructions'+file_count+'" class="layui-input" placeholder="附件说明">'+
                            '<i class="layui-icon layui-icon-reduce-circle" style="font-size: 30px; color: #000000;line-height: 30px;" id="fileUpload_sc_'+file_count+'"></i>'+
                        '</div>'+
                    '</div>';
    $('#addfilediv').append(newFile);
    uploadFileRender("#fileUpload_"+file_count,"#fileUpload_sc_"+file_count,"#file_span"+file_count);
});

function uploadFileRender(e,uploadimd,name) {
    var uploadfile = upload.render({
        elem: e
        , url: 'ftp/uploadFile'
        , field: "uploadify"     //添加这个属性与后台名称保存一致
        , accept: 'file' //允许上传的文件类型
        ,data:{"fileType":"productwj"}//头像
        , before: function (obj) {
            //预读本地文件示例，不支持ie8
            obj.preview(function (index, file, result) {
                $(name).html(file.name);
                $(name).attr("href",result);
                $(name).attr("download",file.name);
            });
        }
        , done: function (res) {


            //如果上传失败
            if (res.status !=200) {
                return layer.msg('上传失败');
            }
            //上传成功
/*
                var img_sb = file_wdiv.find('.img_sb');
                if(img_sb.length != 0){
                    img_sb.remove();
                }*/

                var ftpPath=res.data[0].ftpPath;
                var fileName=res.data[0].fileName;
                var src=getFtpPath(ftpPath,fileName);
                wjs.push(src);
                return layer.msg('上传成功');

        }
        , error: function () {
            //演示失败状态，并实现重传
            var file_wdiv = $(e).parent();
            var img_sb = file_wdiv.find('.img_sb');
            if(img_sb.length == 0){
                file_wdiv.append('<div class="img_sb"><a class="layui-btn layui-btn-xs demo-reload">重试</a></div>');
                file_wdiv.find('.demo-reload').on('click', function () {
                    uploadfile.upload();
                });
            }
        }
    });



    $(uploadimd).on('click',function () {
        $(uploadimd).parent().parent().remove();
    })
}
function  savemain(data) {
    if(id !="") data.id=id;
    maincode=data.code;
    data.cataCode=cataCode;//所属目录
    data.img=JSON.stringify(imgs);
    data.wj=JSON.stringify(wjs);
    var tf=false;
    $.ajax({
        type : 'post',
        //  url : 'resource/getTree',
        data:JSON.stringify(data),
        url:'productmaininfo/savemain',
        dataType:"json",
         contentType: 'application/json',
        async:false,
        success : function (da) {
            if(da.status==200 ){
                tf= da.data >0 ;
                id=da.data;//
            }
        },
        error: function(data) {
            // layer.msg("获取失败!");
        }
    });
    return tf;
}
//关闭
$("#shutdown").on('click',function () {
    // parent.detab("views/jsp/BasicData/tpl/customerinfo.jsp"+(id==''?'':'?id='+id));
    setTimeout(function () {
        //保存成功则刷新提交过来的界面 并关闭此页面
        parent.detab("views/jsp/BasicData/product.jsp");
        parent.intab("views/jsp/BasicData/product.jsp","产品")
        parent.detab("views/jsp/BasicData/tpl/newupproduct.jsp"+(id==''?'':'?id='+id));
    },1000)
})
function  getoption(objs) {
    var stoptions="<option value=''></option>";
    for(var i=0;i<objs.length;i++){
        stoptions+="<option value='"+objs[i].code+"'>"+objs[i].name+"</option>";
    }
    return stoptions;
}
//图片、文件上传
function upload() {
    upload.render({
        elem: '#logoadd'
        , url: 'ftp/uploadFile'
        , field: "uploadify"     //添加这个属性与后台名称保存一致
        , accept: 'file' //允许上传的文件类型
        ,data:{"fileType":"customerlogo"}//头像
        ,before: function(obj) {
            /*var thin = this;
            obj.preview(function(index, file, result){
                $("#"+thin.id+"").attr('src', result); //图片链接（base64）
            });*/

        }
        ,done: function(res){
            //如果上传失败
            if(res.status !=200){
                return layer.msg('上传失败');
            }else{
                var ftpPath=res.data[0].ftpPath;
                var fileName=res.data[0].fileName;
                var src=getFtpPath(ftpPath,fileName);
                $("#userphotos").attr('src',src);
                $("input[name='logo']")[0].value=src;
            }
            //上传成功
        }
        ,error: function(){
            layer.msg('上传失败,请稍后重试')
        }
    })
}
function delfjinfo(ids) {
    var tf=false;
    $.ajax({
        type : 'post',
        //  url : 'resource/getTree',
        data:{"ids":JSON.stringify(ids)},
        url:'productfjinfo/delfjinfo',
        dataType:"json",
        /* contentType: 'application/json',*/
        async:false,
        success : function (da) {
            if(da.status==200 ){
                tf= da.data >0 ;

            }
        },
        error: function(data) {
            // layer.msg("获取失败!");
        }
    });
    return tf;
}
function refrash() {
    table.reload('producttableid', {
        type:"get"
        ,url:"productfjinfo/selectByPage"
        ,where:{
          "code":code
        },
        page: {
            curr: 1 //重新从第 1 页开始
        }

    }, 'data');
}